<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        width: 200px;
        height: 200px;
        background-color: pink;
      }
    </style>
  </head>
  <body>
    <div></div>
    <script>
      // 获取div
      const div = document.querySelector("div");
      // 鼠标移入事件
      div.addEventListener("mouseenter", function () {
        console.log("鼠标移入");
      });
      // 鼠标移出事件
      div.addEventListener("mouseout", function () {
        console.log("鼠标移出");
      });
    </script>
  </body>
</html>
